package com.jingxi.controller;

import com.jingxi.common.pojo.EUTreeNode;
import com.jingxi.common.pojo.JingXiResult;
import com.jingxi.service.ContentCategaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/content/category")
public class ContentCategaryCotroller {
    @Autowired
    private ContentCategaryService contentCategaryService;

    @RequestMapping("/list")
    @ResponseBody
    public List<EUTreeNode>getContentCallList(@RequestParam(value = "id",defaultValue = "0")Long parentId){
        List<EUTreeNode>list=contentCategaryService.getCategaryList(parentId);
        return list;
    }
    @RequestMapping("/create")
    @ResponseBody
    public JingXiResult createContentCategory(Long parentId,String name){
        JingXiResult result=contentCategaryService.insertContentCategory(parentId,name);
        return result;
    }

    @RequestMapping("/delete")
    @ResponseBody
    public JingXiResult deleteContentCategory(Long parentId,Long id){
        JingXiResult result=contentCategaryService.delectContentCategory(parentId,id);
        return result;
    }
    @RequestMapping("/update")
    @ResponseBody
    public JingXiResult updataContentCategory(Long id,String name){
        JingXiResult result=contentCategaryService.updataContentCategory(id,name);
        return result;
    }




}
